<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:c="http://xmlns.jcp.org/jsf/composite"
	xmlns:p="http://primefaces.org/ui">

<ui:decorate template="/jsp/WEB/pageLayout.xhtml">
	<link type="text/css" rel="stylesheet"
		href="#{request.contextPath}/css/skytefAcesso.css" />

	<ui:define name="centro">
		<h:form id="form">
			<p:growl id="msgs" showDetail="true" />
			<p:panel id="Cadastrar" header="Dados do Setor">

				<p:commandButton value="Novo" update="@form"
					action="#{CadSetorBean.clear()}" icon="ui-icon-plus" />

				<h:outputLabel for="nome" value="Nome* : " />
				<p:inputText id="nome" value="#{CadSetorBean.selTxtNomeSetor}" />
			</p:panel>
			<br />
			<p:panel id="Vincular" header="Vincular - Setor x Categoria">
				<p:panel>
					<table border="0">
						<tr>
							<td>Categorias para seleção</td>
							<td></td>
							<td>Vínculo (Setor X Categoria)</td>
						</tr>
						<tr>
							<td width="305" height="100" valign="top"><p:tree
									value="#{CadSetorBean.root}" var="node" dynamic="false"
									selectionMode="single" expandAnim="FADE_IN"
									collapseAnim="FADE_OUT"
									selection="#{CadSetorBean.selectedNode}">
									<p:treeNode>
										<h:outputText value="#{node.getDescription()}" />
									</p:treeNode>
								</p:tree></td>
							<td width="50" height="100" align="center"><p:commandButton
									value="" update="@form" action="#{CadSetorBean.addSetCat()}"
									icon="ui-icon-seek-next" style="width:30px;height:30px" /> <p:commandButton
									value="" update="@form" action="#{CadSetorBean.excSetCat()}"
									icon="ui-icon-seek-prev" style="width:30px;height:30px" /></td>
							<td width="200" height="100" valign="top"><p:selectOneListbox
									id="lstSetCat"
									value="#{CadSetorBean.selSetorCateg.idCategoria}"
									style="width:305px;height:100px">
									<f:selectItems value="#{CadSetorBean.lstSetorCateg}"
										var="SelCat" itemLabel="#{SelCat.desc}"
										itemValue="#{SelCat.idCategoria}" />
								</p:selectOneListbox></td>
						</tr>
					</table>
				</p:panel>
				<p:separator />
				<p:commandButton value="Gravar" update="@form"
					action="#{CadSetorBean.save()}" icon="ui-icon-disk" />
			</p:panel>

			<p:panel id="Lista" header="Listagem de Setores">
				<p:dataTable id="listaSetores" var="set"
					value="#{CadSetorBean.lstSetor}" emptyMessage="Vazio"
					style="margin-top:20px; position: auto" paginator="true"
					selectionMode="single" selection="#{CadSetorBean.selSetor}"
					rowKey="#{set.idSetor}">

					<p:ajax event="rowSelect" update="@form"
						listener="#{CadSetorBean.showDataGridSel()}" />

					<p:column headerText="Id">
						<h:outputText value="#{set.idSetor}" />
					</p:column>

					<p:column headerText="Descrição">
						<h:outputText value="#{set.descricao}" />
					</p:column>
				</p:dataTable>
			</p:panel>
		</h:form>
	</ui:define>
</ui:decorate>
</html>
